import 'package:flutter/material.dart';

import 'package:get/get.dart';
import 'package:getwidget/colors/gf_color.dart';
import 'package:getwidget/components/card/gf_card.dart';
import 'package:getwidget/components/radio/gf_radio.dart';
import 'package:getwidget/size/gf_size.dart';
import 'package:getwidget/types/gf_radio_type.dart';

import '../controllers/gfradio_controller.dart';

class GfradioView extends GetView<GfradioController> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('单选框'),
        centerTitle: true,
      ),
      body: Container(
        child: ListView(
          children: [
            SizedBox(height: 10,),
            Obx(() {
              return Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  GFRadio(
                    size: GFSize.SMALL,
                    value: 2,
                    groupValue: controller.groupValue.value,
                    onChanged: (value) {
                      print(value);
                      controller.groupValue.value = value as int;
                    },
                    inactiveIcon: null,
                    activeBorderColor: GFColors.SUCCESS,
                    radioColor: GFColors.SUCCESS,
                  ),
                  SizedBox(width: 10,),
                  Text(
                    '同意',
                    style: Theme.of(context).textTheme.headline6
                  )
                ],
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFRadio(
                      size: GFSize.LARGE,
                      activeBorderColor: GFColors.SUCCESS,
                      value: 0,
                      groupValue: controller.groupValue.value,
                      onChanged: (val) {
                        controller.groupValue.value = val as int;
                      },
                      inactiveIcon: null,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      size: GFSize.MEDIUM,
                      value: 1,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      size: GFSize.SMALL,
                      value: 2,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      size: 20,
                      value: 3,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    )
                  ],
                )
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFRadio(
                      type: GFRadioType.square,
                      size: GFSize.LARGE,
                      activeBorderColor: GFColors.SUCCESS,
                      value: 0,
                      groupValue: controller.groupValue.value,
                      onChanged: (val) {
                        controller.groupValue.value = val as int;
                      },
                      inactiveIcon: null,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.square,
                      size: GFSize.MEDIUM,
                      value: 1,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.square,
                      size: GFSize.SMALL,
                      value: 2,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.square,
                      size: 20,
                      value: 3,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    )
                  ],
                )
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFRadio(
                      type: GFRadioType.blunt,
                      size: GFSize.LARGE,
                      activeBorderColor: GFColors.SUCCESS,
                      value: 0,
                      groupValue: controller.groupValue.value,
                      onChanged: (val) {
                        controller.groupValue.value = val as int;
                      },
                      inactiveIcon: null,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.blunt,
                      size: GFSize.MEDIUM,
                      value: 1,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.blunt,
                      size: GFSize.SMALL,
                      value: 2,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.blunt,
                      size: 20,
                      value: 3,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    )
                  ],
                )
              );
            }),

            Obx(() {
              return GFCard(
                content: Row(
                  mainAxisAlignment: MainAxisAlignment.spaceBetween,
                  children: <Widget>[
                    GFRadio(
                      type: GFRadioType.custom,
                      activeIcon: Icon(Icons.check),
                      radioColor: Colors.red,
                      size: GFSize.LARGE,
                      activeBgColor: GFColors.SUCCESS,
                      inactiveBorderColor: GFColors.DARK,
                      activeBorderColor: GFColors.SUCCESS,
                      value: 0,
                      groupValue: controller.groupValue.value,
                      onChanged: (val) {
                        controller.groupValue.value = val as int;
                      },
                      inactiveIcon: null,
                    ),
                    GFRadio(
                      type: GFRadioType.custom,
                      activeIcon: Icon(Icons.sentiment_satisfied),
                      size: GFSize.MEDIUM,
                      value: 1,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: Icon(Icons.sentiment_dissatisfied),
                      customBgColor: GFColors.WARNING,
                      activeBgColor: GFColors.SUCCESS,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.blunt,
                      size: GFSize.SMALL,
                      value: 2,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    ),
                    GFRadio(
                      type: GFRadioType.blunt,
                      size: 20,
                      value: 3,
                      groupValue: controller.groupValue.value,
                      onChanged: (value) {
                        controller.groupValue.value = value as int;
                      },
                      inactiveIcon: null,
                      activeBorderColor: GFColors.SUCCESS,
                      radioColor: GFColors.SUCCESS,
                    )
                  ],
                )
              );
            }),

            
          ],
        ),
      ),
    );
  }
}
